package 对象之封装.圆的面积与周长类;

//圆的面积与周长
public class text {
    public static void main(String[] args) {

        Circle c = new Circle(3);
        c.getArea();
        c.getPerimeter();

        Rect r = new Rect(4, 3);
        r.getArea();
        r.getPerimeter();
    }
}

abstract class Shape {
    abstract void getArea();

    abstract void getPerimeter();
}

class Circle extends Shape {
    double r;

    public Circle(double r) {
        this.r = r;
    }

    @Override
    void getArea() {
        System.out.println("半径为" + r + "的圆的面积是" + 3.14 * r * r);
    }

    @Override
    void getPerimeter() {
        System.out.println("半径为" + r + "的圆的周长是" + 3.14 * 2 * r);
    }
}

class Rect extends Shape {
    double a, b;

    public Rect(double a, double b) {
        this.a = a;
        this.b = b;
    }

    @Override
    void getArea() {
        System.out.println("");
    }

    @Override
    void getPerimeter() {
        System.out.println("");
    }
}
